/*++

Copyright (c) 2013 Minoca Corp.

    This file is licensed under the terms of the GNU General Public License
    version 3. Alternative licensing terms are available. Contact
    info@minocacorp.com for details. See the LICENSE file at the root of this
    project for complete licensing information.

Module Name:

    uskeys.c

Abstract:

    This module translates between the key enum and console characters.

Author:

    Evan Green 13-Mar-2013

Environment:

    Kernel

--*/

//
// ------------------------------------------------------------------- Includes
//

#include "inputp.h"

//
// ---------------------------------------------------------------- Definitions
//

//
// Fun fact from Wikipedia: The rubout character got its code from the fact
// that all its ASCII bits are set. In the punch card days if there was a
// mistake in the punching, one could simply punch all the holes in that row to
// rub out the bad character.
//

#define CHARACTER_CODE_RUBOUT       0x7F
#define CHARACTER_CODE_CENTS        0xA2
#define CHARACTER_CODE_PLUS_MINUS   0xB1

//
// ------------------------------------------------------ Data Type Definitions
//

//
// ----------------------------------------------- Internal Function Prototypes
//

//
// -------------------------------------------------------------------- Globals
//

UCHAR InKeyboardCharacters[KeyboardKeyMax] = {
    '\0', /* 00 */
    ANSI_ESCAPE_CODE,
    '1',
    '2',
    '3',
    '4',
    '5',
    '6',
    '7',
    '8',
    '9',
    '0',
    '-',
    '=',
    CHARACTER_CODE_RUBOUT,
    '\t',
    'q',  /* 10 */
    'w',
    'e',
    'r',
    't',
    'y',
    'u',
    'i',
    'o',
    'p',
    '[',
    ']',
    '\r',
    '\0',
    'a',
    's',
    'd',  /* 20 */
    'f',
    'g',
    'h',
    'j',
    'k',
    'l',
    ';',
    '\'',
    '`',
    '\0',
    '\\',
    'z',
    'x',
    'c',
    'v',
    'b',  /* 30 */
    'n',
    'm',
    ',',
    '.',
    '/',
    '\0',
    '*',
    '\0',
    ' ',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* 40 */
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* 50 */
    '\0',
    '\0',
    '\0',
    '\0',
    '0',
    '1',
    '2',
    '3',
    '4',
    '5',
    '6',
    '7',
    '8',
    '9',
    '-',
    '+',  /* 60 */
    '.',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* 70 */
    '\0',
    '\0',
    '\r',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\r',
    '\0',
    '\0', /* 80 */
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* 90 */
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\\',
    '\0',
    '/',
    '\0', /* A0 */
    '\0',
    '=',
    '\0',
    '\0',
    '\0',
    '\0',
    ',',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* B0 */
    '\0',
    ',',
    '.',
    '$',
    CHARACTER_CODE_CENTS,
    '(',
    ')',
    '{',
    '}',
    '\t',
    CHARACTER_CODE_RUBOUT,
    'A',
    'B',
    'C',
    'D',
    'E',  /* C0 */
    'F',
    '\0',
    '^',
    '%',
    '<',
    '>',
    '&',
    '\0',
    '|',
    '\0',
    ':',
    '#',
    ' ',
    '@',
    '!',
    '\0', /* D0 */
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    CHARACTER_CODE_PLUS_MINUS,
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0'
};

UCHAR InShiftedKeyboardCharacters[KeyboardKeyMax] = {
    '\0', /* 00 */
    ANSI_ESCAPE_CODE,
    '!',
    '@',
    '#',
    '$',
    '%',
    '^',
    '&',
    '*',
    '(',
    ')',
    '_',
    '+',
    '\b',
    '\t',
    'Q',  /* 10 */
    'W',
    'E',
    'R',
    'T',
    'Y',
    'U',
    'I',
    'O',
    'P',
    '{',
    '}',
    '\r',
    '\0',
    'A',
    'S',
    'D',  /* 20 */
    'F',
    'G',
    'H',
    'J',
    'K',
    'L',
    ':',
    '"',
    '~',
    '\0',
    '|',
    'Z',
    'X',
    'C',
    'V',
    'B',  /* 30 */
    'N',
    'M',
    '<',
    '>',
    '?',
    '\0',
    '*',
    '\0',
    ' ',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* 40 */
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* 50 */
    '\0',
    '\0',
    '\0',
    '\0',
    '0',
    '1',
    '2',
    '3',
    '4',
    '5',
    '6',
    '7',
    '8',
    '9',
    '-',
    '+',  /* 60 */
    '.',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* 70 */
    '\0',
    '\0',
    '\r',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\r',
    '\0',
    '\0', /* 80 */
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* 90 */
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '|',
    '\0',
    '/',
    '\0', /* A0 */
    '\0',
    '=',
    '\0',
    '\0',
    '\0',
    '\0',
    ',',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0', /* B0 */
    '\0',
    ',',
    '.',
    '$',
    CHARACTER_CODE_CENTS,
    '(',
    ')',
    '{',
    '}',
    '\t',
    CHARACTER_CODE_RUBOUT,
    'A',
    'B',
    'C',
    'D',
    'E',  /* C0 */
    'F',
    '\0',
    '^',
    '%',
    '<',
    '>',
    '&',
    '\0',
    '|',
    '\0',
    ':',
    '#',
    ' ',
    '@',
    '!',
    '\0', /* D0 */
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    CHARACTER_CODE_PLUS_MINUS,
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0',
    '\0'
};

//
// ------------------------------------------------------------------ Functions
//

//
// --------------------------------------------------------- Internal Functions
//

